/**
 * Copyright (C), 2018-2018, https://blog.fundodoo.com
 * Author:   醉探索戈壁
 * Date:     2018/7/10 下午7:38
 * Description: Result
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.fundodoo.blog.aggrid.model;

import com.fasterxml.jackson.annotation.JsonBackReference;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.persistence.*;

/**
 *
 * @author 醉探索戈壁
 * @create 2018/7/10 下午7:38
 * @since 1.0.0
 */
@Entity
@Data
@ToString
@EqualsAndHashCode
public class Result {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Version()
    private Long version = 0L;

    @JsonBackReference
    @ManyToOne(cascade = CascadeType.ALL)
    private Athlete athlete;

    private int age;
    private int year;
    private String date;
    private int gold;
    private int silver;
    private int bronze;

    @OneToOne()
    private Sport sport;

    public Result() {
    }

    public Result(Sport sport, int age, int year, String date, int gold, int silver, int bronze) {
        this.sport = sport;
        this.age = age;
        this.year = year;
        this.date = date;
        this.gold = gold;
        this.silver = silver;
        this.bronze = bronze;
    }
}
